const hbs = require('hbs');
const path = require('path');
const helpers = require('handlebars-helpers');

hbs.registerPartials(path.join(__dirname, '../../views/common'));

helpers.comparison({handlebars: hbs.handlebars});

const blocks = {};
hbs.registerHelper('extend', function (name, context) {
    let block = blocks[name];
    if (!block) {
        block = blocks[name] = [];
    }
    block.push(context.fn(this));
});

hbs.registerHelper('block', function (name) {
    const val = (blocks[name] || []).join('\n');
    blocks[name] = [];
    return val;
});

hbs.registerHelper('whichPartial', function (name) {
    return name;
});

